Skip to content

test(presets): silence expected UserWarnings in self-test composition…#2373

Open
Quratulain-bilal wants to merge 5 commits intogithub:mainfrom
Quratulain-bilal:fix/preset-test-warnings
Open

test(presets): silence expected UserWarnings in self-test composition…#2373
Quratulain-bilal wants to merge 5 commits intogithub:mainfrom
Quratulain-bilal:fix/preset-test-warnings

Conversation

@Quratulain-bilal
Copy link
Copy Markdown
Contributor

@Quratulain-bilal Quratulain-bilal commented Apr 26, 2026

Summary

Fixes #2363tests/test_presets.py produces 18 unhandled UserWarnings when the self-test preset is installed during
tests.

Root cause

The repo's presets/self-test/ preset provides speckit.wrap-test, a wrap-strategy command intentionally without a
base layer
to exercise that code path. _reconcile_composed_commands() in presets.py:786 deliberately emits
UserWarning("Cannot compose command 'speckit.wrap-test': no base layer...") and a follow-up "Post-install reconciliation failed..." warning — these are expected for this fixture but were not acknowledged at the test level.

Fix

Per the issue's option #2, add @pytest.mark.filterwarnings(...) decorators on TestSelfTestPreset and
TestPresetSkills for the two known messages. Other UserWarning sources still propagate normally so future
regressions remain visible.

Verification

pytest tests/test_presets.py::TestSelfTestPreset tests/test_presets.py::TestPresetSkills -W error::UserWarning
# 36 passed
pytest tests/test_presets.py
# 241 passed

Test plan

- Targeted tests pass under -W error::UserWarning
- Full tests/test_presets.py suite passes (241/241)
- CI green

… tests

The self-test preset that ships with the repo provides a wrap-strategy
command (speckit.wrap-test) intentionally without a corresponding core
base layer, exercising the 'no base layer' branch of
_reconcile_composed_commands().

Eighteen tests across TestSelfTestPreset and TestPresetSkills install
this preset and trigger an expected UserWarning. Running the suite with
-W error::UserWarning surfaces them as test noise that could obscure
unrelated warnings.

Add class-level pytest.mark.filterwarnings filters to acknowledge the
two known messages ('Cannot compose command speckit.wrap-test' and
'Post-install reconciliation failed for self-test') so other UserWarning
sources still propagate normally.

Fixes github#2363
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Reduces test-suite noise in preset composition tests by explicitly acknowledging two expected UserWarnings emitted when installing the repo’s self-test preset (which intentionally includes a wrap-strategy command without a base layer).

Changes:

  • Add class-level pytest.mark.filterwarnings(...) entries to silence two known, expected warning messages.
  • Expand docstrings on the affected test classes to document why the warnings are expected.
Show a summary per file
File Description
tests/test_presets.py Adds targeted warning filters to keep self-test preset composition tests quiet while preserving visibility of other warnings.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comments suppressed due to low confidence (1)

tests/test_presets.py:2207

  • Same as above: these filterwarnings patterns omit the warning category, which makes the ignore broader than necessary. Adding :UserWarning would keep the suppression tightly scoped to the expected warnings.
@pytest.mark.filterwarnings(
    r"ignore:Cannot compose command 'speckit\.wrap-test'"
)
@pytest.mark.filterwarnings(
    r"ignore:Post-install reconciliation failed for self-test"
)
  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread tests/test_presets.py Outdated
Address Copilot review on github#2373: the previous filterwarnings entries
omitted the warning category, so any warning class with a matching
message would have been silenced. Append :UserWarning to the four
filters so only the deliberately-emitted UserWarnings from
_reconcile_composed_commands() are ignored.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 0 new

mnriem
mnriem previously approved these changes Apr 27, 2026
@Quratulain-bilal
Copy link
Copy Markdown
Contributor Author

Rebased onto latest main and resolved the conflict in tests/test_presets.py in ad2fdcf. Kept the
helper-based install_self_test_preset approach from main since the class-level
@pytest.mark.filterwarnings decorators would have been redundant once every test calls the helper.
Branch is now clean —happy to address any further feedback.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread tests/test_presets.py Outdated
Comment on lines +2246 to +2251
@pytest.mark.filterwarnings(
r"ignore:Cannot compose command 'speckit\.wrap-test':UserWarning"
)
@pytest.mark.filterwarnings(
r"ignore:Post-install reconciliation failed for self-test:UserWarning"
)
@mnriem
Copy link
Copy Markdown
Collaborator

mnriem commented May 5, 2026

Please address Copilot feedback. If not applicable, please explain why

Address Copilot feedback: the class-level @pytest.mark.filterwarnings on
TestPresetSkills was too broad. The 'Post-install reconciliation failed'
filter could mask real reconciliation regressions, since that warning is
only emitted when _reconcile_composed_commands/_reconcile_skills raises.

Tests in TestPresetSkills already call install_self_test_preset(), which
scopes a narrow filter to the expected wrap-strategy 'Cannot compose'
warning. The class-level filters are redundant for those calls and unsafe
elsewhere, so they are removed.
@Quratulain-bilal
Copy link
Copy Markdown
Contributor Author

@mnriem! Addressed Copilot's feedback in 6d3d6de.

The class-level @pytest.mark.filterwarnings on TestPresetSkills was indeed too broad Post-install reconciliation failed for self-test is only emitted when _reconcile_composed_commands /
_reconcile_skills raise an exception, so silencing it could have masked real regressions. Tests in
this class already call install_self_test_preset(), which scopes a narrow filter to the expected
wrap-strategy warning, so the class-level decorators are redundant. Removed them; full

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 1/1 changed files
  • Comments generated: 1

Comment thread tests/test_presets.py
Comment on lines +1953 to +1959
"""Tests using the self-test preset that ships with the repo.

The self-test preset ships a wrap-strategy command (``speckit.wrap-test``)
without a corresponding core base layer; reconciliation deliberately
surfaces a UserWarning in that case. The filters above acknowledge those
expected warnings so the suite stays quiet without masking unrelated ones.
"""
@mnriem
Copy link
Copy Markdown
Collaborator

mnriem commented May 5, 2026

Please address Copilot feedback

…iltering

Address Copilot feedback: docstring referred to 'filters above', but the
fix uses warnings.filterwarnings inside install_self_test_preset rather
than class-level decorators. Updated the docstring to describe the actual
mechanism.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test(presets): 18 unhandled UserWarnings in composition tests

3 participants